package com.winit.deploy.util;

import com.alibaba.fastjson.JSONObject;
import com.winit.common.util.SpringContextHolder;
import com.winit.core.mq.exchange.MessageExchange;
import com.winit.core.mq.message.Message;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.HashMap;
import java.util.Map;

/**
 * 发布相关消息发送
 * Created by wangjian on 16/12/9.
 */
public class DeployMessageUtil {

    private static Logger logger = LoggerFactory.getLogger(DeployMessageUtil.class);

    public static void tomcatStopType(String queueName,String envName,String areaName,String taskId
            ,String msg){
        logger.info("com.winit.deploy.util.DeployMessageUtil.tomcatStopType queueName="+queueName+",envName="+envName
                +",areaName="+areaName+",taskId="+taskId+",msg="+msg);
        Map head = new HashMap();
        head.put("queueName",queueName);
        head.put("envName",envName);
        head.put("areaName",areaName);
        head.put("type","tomcatStopType");

        JSONObject object = new JSONObject();
        object.put("id",taskId);
        object.put("msg",msg);

        Message<JSONObject> message = new Message<>(head,object);
        MessageExchange messageExchange = SpringContextHolder.getBean(MessageExchange.class);
        messageExchange.sendMessage(queueName,message);
    }

}
